import axios from "axios";
import qs from 'query-string';


// let baseUrl = 'http://116.62.149.160:5000'
// let baseUrl = 'http://localhost:5000'

let baseUrl = 'http://116.62.149.160:5000'
// let baseUrl = 'http://localhost:4000'


export async function request(url:string ,params:object , method: string){    
    const serve = await axios({
        method,
        url:baseUrl+url,
        // withCredentials:true,
        data:qs.stringify(params),
        headers:{
            "Content-Type": "application/x-www-form-urlencoded",
            "token": localStorage.getItem(import.meta.env.VITE_APP_TOKEN) as string,
        }
    })
    
    return serve.data
}

export default request